//
//  CategoryCollectionCell.m
//  Atlantis
//
//  Created by 何恩营 on 14-12-20.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "CategoryCollectionCell.h"
#import "UIImageView+WebCache.h"
#import "AVPlayer+player.h"

@interface CategoryCollectionCell ()

// 标题
@property(nonatomic, retain) UILabel *titleLabel;
// 图片
@property(nonatomic, retain) UIImageView *collImageView;

@end

@implementation CategoryCollectionCell

// 内存管理
- (void)dealloc
{
    [_music release];
    [_collImageView release];
    [_titleLabel release];
    [super dealloc];
}


// 初始化
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        // 发现页面的collectionView的图片
        self.collImageView = [[UIImageView alloc] init];
        // 将图片视图加载到自定义cell视图上
        [self.contentView addSubview:self.collImageView];
        [_collImageView release];
        
        // 发现页面的collectionView的标题
        self.titleLabel = [[UILabel alloc] init];
        // 将标题视图加载到自定义cell视图上
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        //  NSLog(@"%f", self.contentView.frame.size.width);
    }
    return self;
}

// 重写纠错
- (void)setMusic:(Music *)sound
{
    // 判断是否为同一对象
    if (_music != sound) {
        [_music release];
        _music = [sound retain];
    }
    
    // 自定义cell的图片设置大小
    self.collImageView.frame = CGRectMake(10, 5, self.contentView.bounds.size.width - 20, self.contentView.frame.size.width - 20);
    // 设置弧度
    self.collImageView.layer.cornerRadius = self.collImageView.frame.size.width / 2;
    // 设置界限
    self.collImageView.layer.masksToBounds = YES;
    // 赋值
    [self.collImageView setImageWithURL:[NSURL URLWithString:self.music.coverLarge]];
    
    
    
    
    // 自定义cell的标题设置大小
    self.titleLabel.frame = CGRectMake(10, self.contentView.bounds.size.height - 45, self.contentView.bounds.size.width - 20, 40);
    // 不限行数
    self.titleLabel.numberOfLines = 0;
    // 赋值
    self.titleLabel.text = self.music.title;
    // 字体居中
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    // 设置文字大小
    self.titleLabel.font = [UIFont fontWithName:nil size:14];
    
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
}



@end
